<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改服务对话列')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-service-edit" th:object="${qService}">
        <input name="serviceId" th:field="*{serviceId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">客户姓名：</label>
            <div class="col-sm-8">
                <input name="customerid" th:field="*{customerid}" disabled class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">坐席客服名称：</label>
            <div class="col-sm-8">
                <input name="agentid" th:field="*{agentid}" class="form-control" disabled type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">客户号码：</label>
            <div class="col-sm-8">
                <input name="fromnum" th:field="*{fromnum}" class="form-control" disabled type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">全局录音：</label>
            <div class="col-sm-8">

                <input id="serviceId" type="hidden" name="serviceId" th:field="*{serviceId}">
                <input id="voxfile" type="hidden" name="voxfile" th:field="*{voxfile}">
                <audio id="myAudio" controls>
                    Your browser does not support the audio element.
                </audio>
            </div>
        </div>



        <div class="form-group">
            <label class="col-sm-3 control-label">呼叫发起时间：</label>
            <div class="col-sm-8">
                <input name="beginTime" th:field="*{beginTime}" class="form-control" disabled type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">呼叫结束时间：</label>
            <div class="col-sm-8">
                <input name="endTime" th:field="*{endTime}" class="form-control" disabled type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">呼叫类型：</label>
            <div class="col-sm-8">
                <input name="isinside" th:field="*{isinside}" class="form-control" disabled type="text">


            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">接听状态：</label>
            <div class="col-sm-8">
                <input name="state" th:field="*{state}" class="form-control" disabled type="text">
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/service";
    $("#form-service-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-service-edit').serialize());
        }
    }

    $(".file-upload").each(function (i) {
        var val = $("input[name='" + this.id + "']").val()
        $(this).fileinput({
            'uploadUrl': ctx + 'common/upload',
            initialPreviewAsData: true,
            initialPreview: [val],
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        $(this).fileinput('_initFileActions');
    });


    $(function () {

        var audio = document.getElementById('myAudio');
        var voxfile = $("#voxfile").val();
        var serviceId = $("#serviceId").val();


        var v1 = 'https://zvoice.oss-cn-beijing.aliyuncs.com/rec' + voxfile + '.mp3';
        var v2 = 'http://111.22.175.38:10081/admin/api/recordplay.php?linkedid=' + serviceId;
        var myDate = new Date();
        myDate.setFullYear(2024, 7, 31);

        var recordTime = $("#beginTime").val();

        if (serviceId.length <= 20) {
            //
            audio.src = v1; // 这里的路径应该指向你的音频文件 7月以前的
            audio.load(); // 加载音频文件
            // audio.play(); // 播放音频
            console.log("Today is before 2024-7-31");
        } else {
            audio.src = v2; // 这里的路径应该指向你的音频文件
            audio.load(); // 加载音频文件
            //   audio.play(); // 播放音频
            console.log("Today is after 2024-7-31");
        }

        var audio = document.getElementById('isinside');
        var isinside = $("#isinside").val();
        if ($("#isinside").val() == '2') {
            $("#isinside").val("呼入")
        } else {
            $("#isinside").val("呼入")
        }
        if ($("#state").val() == '5') {
            $("#state").val("未接通")
        } else {
            $("#state").val("已接通")
        }
        console.log(isinside);

    });
</script>
</body>
</html>